//
//  HLBReimburseVC.m
//  dyseller
//
//  Created by 红喇叭 on 2017/12/8.
//  Copyright © 2017年 红喇叭. All rights reserved.
//

#import "HLBReimburseVC.h"
#import "ReimburseCell.h"

@interface HLBReimburseVC ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *reimburseTableView;
@property(nonatomic,strong)NSMutableArray *reimburseArray;
@end

@implementation HLBReimburseVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavTitle:@"退款统计" titleColor:kBlackColor font:font17];
    [self.view addSubview:self.reimburseTableView];
    [self getorderRefundList];
}

///ShopApi/Analyze/orderRefundList
- (void)getorderRefundList{
    __weak typeof (self)weakself = self;
    [[PPHttpRequsetData shareInstance] requestStyle:Request_POST URL:@"/ShopApi/Analyze/orderRefundList" parameter:@{} successBlock:^(PPHttpRequest *request, NSArray* responseObj) {
        
        _reimburseArray = responseObj.mutableCopy;
        [weakself.reimburseTableView reloadData];
        
    } failBlock:^(PPHttpRequest *request, NSString *errMsg) {
        
        [AlertUtils showHint:errMsg];
    }];

}

#pragma  mark ========懒加载========
- (UITableView *)reimburseTableView{
    if(_reimburseTableView == nil){
        _reimburseTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H-TabBarItemHeight-NavigationHeight+49) style:UITableViewStylePlain];
        _reimburseTableView.dataSource = self;
        _reimburseTableView.delegate = self;
        _reimburseTableView.estimatedRowHeight = 60;
        
        _reimburseTableView.tableFooterView = [UIView new];
        _reimburseTableView.tableHeaderView = [UIView new];
        [_reimburseTableView registerClass:[ReimburseCell class] forCellReuseIdentifier:@"ReimburseCell"];
        _reimburseTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
    }
    return _reimburseTableView;
}

#pragma  mark ========UITableViewDelegate,UITableViewDataSource========
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  _reimburseArray.count;
}

/*{
 "id": "45824",
 "goods_name": "韭菜猪红",
 "goods_price": "5.00",
 "goods_image": "https://img.honglaba.com/Static/Uploads/Goods_pic/2017-09-27/59cb588728a5b.jpg",
 "order_total": "0"
 },*/

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSDictionary *dic = _reimburseArray[indexPath.row];
    ReimburseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReimburseCell" forIndexPath:indexPath];
    //jinen_Price.text = @"￥ 100";
    cell.orderNumber.text = dic[@"order_sn"];
    cell.orderprice.text = [NSString stringWithFormat:@"￥ %@",dic[@"refund_money"]];
    cell.remburseTimer.text = dic[@"add_time"];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 200;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 0.1)];
    
    
    
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.1;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    return [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 0.1)];
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}


@end
